package com.llyb.controller;

import cn.hutool.core.date.DateUtil;
import com.llyb.inter.ChatPersistenceAssistant;
import dev.langchain4j.model.chat.ChatModel;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class persistenceChatModelController {

    @Autowired
    private ChatPersistenceAssistant chatPersistenceAssistant;

    @Resource
    private ChatModel chatModel;

    // http://localhost:9010/chatpersistence/chat1
    @GetMapping("/chatpersistence/chat1")
    public String chatStream() {

        String chat = chatPersistenceAssistant.chatWithChatMemory(1L,"什么是知识产权？");
        System.out.println(chat);

        String chat2 = chatPersistenceAssistant.chatWithChatMemory(2L,"什么是java？");
        System.out.println(chat2);

        String chat3 = chatPersistenceAssistant.chatWithChatMemory(3L,"介绍下西瓜和芒果");
        System.out.println(chat3);

        String chat4 = chatPersistenceAssistant.chatWithChatMemory(4L,"飞机发动机原理");
        System.out.println(chat4);

        return "success : "+ DateUtil.now()+"<br> \n\n chat: "+chat+"<br> \n\n chat2: "+chat2;
    }


}
